//删除表格操作-(通用方法)
function delet(i) {
	   if (window.confirm("您确定要删除文件夹么？")) {
	             mydata.splice(i, 1);  
				 table_1();	  
		} else {
		return;
	}
   
	
   
}
//修改表格界面
function revise(i) {
    d5.innerHTML = `
    <div class="revise">
        <div>
            <div class="input-group">
                <span class="input-group-addon">
                    作废状态
                </span>
                <input type="text" class="form-control" value="${mydata[i].OrderID}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    订单状态
                </span>
                <input type="text" class="form-control" value="${mydata[i].CusName}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    出库日期
                </span>
                <input type="text" class="form-control" value="${mydata[i].State}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    订单号
                </span>
                <input type="text" class="form-control" value="${mydata[i].State}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    客户名称
                </span>
                <input type="text" class="form-control" value="${mydata[i].State}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    制单员
                </span>
                <input type="text" class="form-control" value="${mydata[i].State}">
            </div>
            <div class="input-group">
                <span class="input-group-addon">
                    备注
                </span>
                <input type="text" class="form-control" value="${mydata[i].State}">
            </div>
            <div class="input-group" style="margin-top:20px;display: flex; justify-content: space-around;">
                <button class="btn btn-info" onclick="revise_in(${i})">修改</button>
                <button class="btn btn-danger" onclick="revise_out()">退出</button>
            </div>
        </div>
    </div>`


}

//添加表格页面
function addtion() {

    //为数组才行
    if (mydata.length > 0) {
        d5.innerHTML = `
        <div class="revise">
            <div>
                <div class="input-group">
                    <span class="input-group-addon">
                        作废状态
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        订单状态
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        出库日期
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        订单号
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        客户名称
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        制单员
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">
                        备注
                    </span>
                    <input type="text" class="form-control">
                </div>
                <div class="input-group" style="margin-top:20px;display: flex; justify-content: space-around;">
                    <button class="btn btn-info" onclick="add()">添加</button>
                    <button class="btn btn-danger" onclick="revise_out()">退出</button>
                </div>
            </div>
        </div>`} else {
        alert('没有数据');
    }
}
//修改表格
function revise_in(i){
    console.log(1);
    var obj = { "UName": "测试", "CusName": $(".revise>div>div:nth-child(2)>input:nth-child(2)").val(), "StuOrderOutCusID": "20210129220634140", "OrderID": $(".revise>div>div:nth-child(1)>input:nth-child(2)").val(), "CusID": $(".revise>div>div:nth-child(3)>input:nth-child(2)").val(), "Functionary": "", "StatusID": "待审核", "SHUserID": null, "SHDate": null, "RemindDate": "\/Date(1611929906980)\/", "OutPrice": 0.00, "State": $(".revise>div>div:nth-child(3)>input:nth-child(2)").val(), "Remark": "", "Memo": "", "DWght_BiLi": 6.00, "IsDQ": false, "IsDel": false, "DelTime": null, "UserID": "20201120140242853", "CDate": "\/Date(1611929907027)\/" }
    //对数组进行删除替换
    mydata.splice(i, 1, obj);
    // 修改后临时关闭页面,并且跟新
    table_1();revise_out();
}
//添加方法
function add(){
   
    var obj = { "UName": "测试", "CusName":$(".revise>div>div:nth-child(2)>input:nth-child(2)").val(), "StuOrderOutCusID": "20210129220634140", "OrderID": $(".revise>div>div:nth-child(1)>input:nth-child(2)").val(), "CusID": $(".revise>div>div:nth-child(3)>input:nth-child(2)").val(), "Functionary": "", "StatusID": "待审核", "SHUserID": null, "SHDate": null, "RemindDate": "\/Date(1611929906980)\/", "OutPrice": 0.00, "State": $(".revise>div>div:nth-child(3)>input:nth-child(2)").val(), "Remark": "", "Memo": "", "DWght_BiLi": 6.00, "IsDQ": false, "IsDel": false, "DelTime": null, "UserID": "20201120140242853", "CDate": "\/Date(1611929907027)\/" }
    //将对象添加到数组
    mydata.push(obj);
     // 添加后临时关闭页面,并且跟新
     table_1();revise_out();
}
//去除临时页面
function revise_out(){ 
    d5.innerHTML = '';
}